﻿var sp_isRefash = false;
var NodeId = UrlParm.parm('nodeid');
function window_onbeforeunload() {
    if (!sp_isRefash) {
        var str = "";
        str = "你的数据还未保存，您真的要关闭窗口吗？";
        return str;
    } else {
        //return false;
    }
}
function doing(action, parm) {
    if (action == 'createContent') {
        frames["contentedit"].location = 'content_save.aspx?ac=add&nodeid=' + NodeId;
    }
    else if (action == 'saveContent') {
        var bt_Submit = frames.contentedit.$('#btnSubmit');
        //alert(bt_Submit);
        bt_Submit.click();
    }
    else if (action == 'close') {
        sp_isRefash = true;
        window.close();
    }
    else if (action == 'changeNode') {
        NodeId = $("#ddlNodeSel").val();
        frames["contentedit"].location = 'content_save.aspx?ac=add&nodeid=' + NodeId;
    }
}

function setLoadcontentedit() {
    var _th = $("#msviLocalToolbar").height();
    var _doch = $(document).height();
   // alert(_th+"!"+_doch);
    $("#contentedit").height(_doch - _th - 10);
}

$(document).ready(function() {
    var action = UrlParm.parm('ac');
    if (action == "add") {
        frames["contentedit"].location = 'content_save.aspx?ac=add&nodeid=' + NodeId;
        setLoadcontentedit();
    } else if (action == "edit") {
        var id = UrlParm.parm('id');
        frames["contentedit"].location = 'content_save.aspx?ac=edit&nodeid=' + NodeId + "&id=" + id;
        setLoadcontentedit();
    }
    else if (action == "resetnode") {
        $("#msviLocalToolbar").hide();
        $("#task").show();
        sp_isRefash = true;
        window.location = 'admin_publish.aspx?nodeid=' + NodeId + '&ac=RePubContent&refer=' + encodeURI('admin_publish_list.aspx?nodeid=' + NodeId) + '&t=' + Math.random();
    } else {
        frames["contentedit"].location = 'content_save.aspx?ac=add&nodeid=' + NodeId;
        setLoadcontentedit();
        setLoadcontentedit();
    }

});

window.onbeforeunload = window_onbeforeunload;
window.onresize = setLoadcontentedit;